// 通过remote模块调用主进程的menu模块
const remote = require('@electron/remote')

const Menu = remote.Menu
//  配置右键菜单，按角色来配置
const contextTemplate = [
  { label: '复制', role: 'copy' },
  { label: '粘贴', role: 'paste' },
  { label: '剪切', role: 'cut' },
]
let menuBuilder = Menu.buildFromTemplate(contextTemplate)

window.onload = () => {
  // 监听上下文菜单行为
  window.addEventListener('contextmenu', (e) => {
    // 阻止右键菜单的默认
    e.preventDefault()
    // 弹出窗口
    menuBuilder.popup({ window: remote.getCurrentWindow() })
  }, false)
}
